package com.lee.dhsg.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.DateFormat;
import java.util.Date;

/**
 * 该控制器用于第一次测试
 *
 * @author Lee
 */

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public String hello(Model m) throws Exception {
        m.addAttribute("now", DateFormat.getDateTimeInstance().format(new Date()));

        //测试异常抛出后被捕获，并跳转到errorPage.jsp页面
        if (false) {
            throw new Exception("some exception");
        }

//        return "jsp/hello";
        return "coursePlayofS";
    }

    // 以下用于测试 AJAX
    @RequestMapping("/hello/ajax")
    @ResponseBody
    public String helloAjax(){
        System.out.println("hello ajax");
        return "Hello Ajax !";
    }

}
